home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / text / manipulation / snap164.lha / frame.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-30  |  1.2 KB  |  67 lines

  1. #if __SASC
  2. #include "snap.h"
  3. #endif
  4.  
  5. IMPORT struct RastPort rp;
  6.  
  7. Point OldFrame[9];
  8. Point NewFrame[9];
  9. LONG OFType = 0;
  10. UWORD Ptrn;
  11.  
  12. STATIC VOID MultiDraw(rp, num, xy)
  13. struct RastPort *rp;
  14. LONG num;
  15. Point *xy;
  16. {
  17.     REGISTER LONG i = 0;
  18.     REGISTER Point *coord = xy;
  19.     while (i<num) {
  20.         Move(rp, (LONG)coord->x, (LONG)coord->y);
  21.         coord++;
  22.         Draw(rp, (LONG)coord->x, (LONG)coord->y);
  23.         i++;
  24.     }
  25. }
  26.  
  27. VOID crawl_frame(dir)
  28. LONG dir;
  29. {
  30.     REGISTER UWORD temp = Ptrn;
  31.     if (dir) {
  32.         Ptrn = ((Ptrn<<1) & 0xfffe) | ((Ptrn & 0x8000)>>15);
  33.     } else {
  34.         Ptrn = ((Ptrn>>1) & 0x7fff) | ((Ptrn & 1)<<15);
  35.     }
  36.     temp ^= Ptrn;
  37.     SetDrPt(&rp, temp);
  38.     MultiDraw(&rp, OFType, &OldFrame[0]);
  39.     SetDrPt(&rp, Ptrn);
  40. }
  41.  
  42. VOID erase_frame()
  43. {
  44.     if (OFType) {
  45.         MultiDraw(&rp, OFType, &OldFrame[0]);
  46.         OFType = 0;
  47.     }
  48. }
  49.  
  50. VOID draw_frame(ft)
  51. LONG ft;
  52. {
  53.     REGISTER LONG i;
  54.       /* Remove old frame */
  55.     WaitTOF();
  56.     erase_frame();
  57.       /* Draw the new frame */
  58.     SetDrPt(&rp, Ptrn);
  59.     MultiDraw(&rp, ft, &NewFrame[0]);
  60.       /* save the frame for erasing later */
  61.     for (i=0; i<=ft; i++) {
  62.         OldFrame[i].x = NewFrame[i].x;
  63.         OldFrame[i].y = NewFrame[i].y;
  64.     }
  65.     OFType = ft;
  66. }
  67.